package entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 *
 * @author WenYong
 */
@Entity(name = "UnstructuredContent")
public class UnstructuredContentEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long unstructuredContentId;
    @OneToMany(cascade = {CascadeType.ALL},orphanRemoval = true, mappedBy = "unstructuredContent")
    private List<UnstructuredContentPageEntity> unstructuredContentPage = new ArrayList<UnstructuredContentPageEntity>();
    @OneToOne
    private StakeholderEntity stakeholder;
    
    public UnstructuredContentEntity(List<UnstructuredContentPageEntity> unstructuredContentPage) {
        this.unstructuredContentPage = unstructuredContentPage;
    }

    public UnstructuredContentEntity(UnstructuredContentEntity temp) {
        this(temp.getUnstructuredContentPage());
    }

    public UnstructuredContentEntity() {
    }

    public Long getUnstructuredContentId() {
        return unstructuredContentId;
    }

    public void setUnstructuredContentId(Long unstructuredContentId) {
        this.unstructuredContentId = unstructuredContentId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (unstructuredContentId != null ? unstructuredContentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof UnstructuredContentEntity)) {
            return false;
        }
        UnstructuredContentEntity other = (UnstructuredContentEntity) object;
        if ((this.unstructuredContentId == null && other.unstructuredContentId != null) || (this.unstructuredContentId != null && !this.unstructuredContentId.equals(other.unstructuredContentId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.UnstructuredContent[ id=" + unstructuredContentId + " ]";
    }

    /**
     * @return the unstructuredContentPage
     */
    public List<UnstructuredContentPageEntity> getUnstructuredContentPage() {
        return unstructuredContentPage;
    }

    /**
     * @param unstructuredContentPage the unstructuredContentPage to set
     */
    public void setUnstructuredContentPage(List<UnstructuredContentPageEntity> unstructuredContentPage) {
        this.unstructuredContentPage = unstructuredContentPage;
    }

    public StakeholderEntity getStakeholder() {
        return stakeholder;
    }

    public void setStakeholder(StakeholderEntity stakeholder) {
        this.stakeholder = stakeholder;
    }
}
